package com.xyp.iodemo.nettyrpcclient;

import com.xyp.iodemo.nettyrpcclient.interfaces.INettyCallBack;
import com.xyp.iodemo.nettyrpcclient.netty.RPCFactory;
import com.xyp.iodemo.nettyrpccommon.api.IUserService;
import com.xyp.iodemo.nettyrpccommon.utils.JsonMapper;

import java.net.InetSocketAddress;
import java.util.logging.Logger;

/**
 * @author xuyuanpeng
 * @version 1.0
 * @date 2019-04-09 21:31
 */
public class Starter {
    private static java.util.logging.Logger logger = Logger.getLogger("Starter");

    public static void main(String [] agres){
        final String host = "127.0.0.1";
        final int port = 8088;
        InetSocketAddress inetSocketAddress=new InetSocketAddress(host, port);
        //TODO 开启服务器
        IUserService userService=RPCFactory.getRemoteProxyObj(IUserService.class,inetSocketAddress,
                new INettyCallBack() {
                    @Override
                    public Object calllBack(Object obj) {
                        logger.info("obj>"+ JsonMapper.toJsonString(obj));
                        return null;
                    }
                });
        userService.getUser("1");
    }
}
